const pool = require("../connection/sqlPool");

async function GETLIKE(foodname) {
    try{
        const promisePool = pool.promise();
        const [rows, fields] = await promisePool.query("SELECT `like` FROM Publish_temporary_storage WHERE `foodname`=?", [foodname]);
        return rows;
    }catch(err){
        return err.message
    }
}

async function ADDLIKE(foodname,like_num) {
    try{
        const promisePool = pool.promise();
        const [rows, fields] = await promisePool.query('UPDATE `Publish_temporary_storage` SET `like` = `like` + ? WHERE `foodname` = ?',[like_num,foodname]);
        return rows;
    }catch(err){
        return err.message
    }
}

module.exports = { GETLIKE, ADDLIKE};